package com.fr.report.highlight;

import com.fr.base.ColumnRow;
import com.fr.base.StringUtils;
import com.fr.base.xml.XMLObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.condition.Condition;
import com.fr.data.condition.ListCondition;
import com.fr.data.condition.ObjectCondition;
import com.fr.data.core.Compare;
import com.fr.data.core.DataXMLUtils;
import com.fr.report.CellElement;
import com.fr.report.script.Calculator;

public class AbstractHighlight
  implements Highlight
{
  private static final long serialVersionUID = -2453532958147936705L;
  private Condition condition;
  private String name;

  public Condition getCondition()
  {
    return this.condition;
  }

  public void setCondition(Condition paramCondition)
  {
    this.condition = paramCondition;
  }

  public String getName()
  {
    return this.name;
  }

  public void setName(String paramString)
  {
    this.name = paramString;
  }

  public boolean eval(CellElement paramCellElement, Calculator paramCalculator)
  {
    if (paramCellElement == null)
      return true;
    paramCalculator.setCurrentColumnRow(ColumnRow.valueOf(paramCellElement.getColumn(), paramCellElement.getRow()));
    return this.condition.eval(paramCellElement.getValue(), paramCalculator);
  }

  public void action(CellElement paramCellElement, Calculator paramCalculator)
  {
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    AbstractHighlight localAbstractHighlight = (AbstractHighlight)super.clone();
    if (this.condition != null)
      localAbstractHighlight.setCondition((Condition)this.condition.clone());
    return localAbstractHighlight;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str2;
      String str1 = paramXMLableReader.getTagName();
      if (str1.equals("Name"))
      {
        if ((str2 = paramXMLableReader.getElementValue()) != null)
          this.name = str2;
      }
      else if (str1.equals("JoinCondition"))
      {
        int i = 0;
        if ((str2 = paramXMLableReader.getAttr("join")) != null)
          i = Integer.parseInt(str2);
        paramXMLableReader.readXMLObject(new XMLObject(this, new Integer(i))
        {
          private final AbstractHighlight this$0;

          public void readXML()
          {
            if (paramXMLableReader.isChildNode())
            {
              String str = paramXMLableReader.getTagName();
              if (("Compare".equals(str)) || (str.equals("Condition")))
              {
                Compare localCompare = new Compare(0, "");
                paramXMLableReader.readXMLObject(localCompare);
                if (AbstractHighlight.access$000(this.this$0) instanceof ListCondition)
                  AbstractHighlight.access$002(this.this$0, new ListCondition());
                ((ListCondition)AbstractHighlight.access$000(this.this$0)).addJoinCondition(((Integer)this.obj).intValue(), new ObjectCondition(localCompare));
              }
            }
          }
        });
      }
      else if ("Condition".equals(str1))
      {
        this.condition = DataXMLUtils.readXMLCondition(paramXMLableReader);
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (StringUtils.isNotBlank(this.name))
      paramXMLPrintWriter.startTAG("Name").textNode(this.name).end();
    DataXMLUtils.writeXMLCondition(paramXMLPrintWriter, this.condition);
  }

  static Condition access$000(AbstractHighlight paramAbstractHighlight)
  {
    return paramAbstractHighlight.condition;
  }

  static Condition access$002(AbstractHighlight paramAbstractHighlight, Condition paramCondition)
  {
    return (paramAbstractHighlight.condition = paramCondition);
  }
}